{% extends "base.html" %}

{% block content %}
<script language=javascript>

function verify(form){
  if(form.name.value==""){
	alert("Enter the name please!");
	form.name.focus();		
       return false;
	}
  if(form.intro.value==""){
	alert("Enter the introduce please!");
	form.intro.focus();		
       return false;
	}
  if(form.imvalue.value==""){
	alert("请输入项目优先级,数值越大越优先!");
	form.imvalue.focus();		
       return false;
	}
	return true;
 }

</script>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center">
	<form name='form1' id='form1' action="/save_pj/" method='post' onsubmit='return verify(this);'>
<table width='80%' class='grid' cellspacing='1' align='center'><tr><td colspan='10' class='title' align="center">Add Programs</td></tr>
<tr valign='middle' align='left'><td class='odd' width='25%'><font color="red">*</font>Name</td>
<td class='even'><input type="text" name="name" value="" /></td></tr>
<tr valign='middle' align='left'><td class='odd' width='25%'><font color="red">*</font>Description</td>
<td class='even'><textarea name="intro" cols="50" rows="5" /></textarea></td></tr>
<tr valign='middle' align='left'><td class='odd' width='25%'><font color="red">*</font>Priority</td>
<td class='even'><input type="text" name="imvalue" value="0" /></td></tr>
<tr valign='middle' align='left'><td class='odd' width='25%'><font color="red">*</font>Position</td>
<td class='even'><input type="text" name="position" value="0" /></td></tr>
<tr valign='middle' align='left'><td class='odd' width='25%'></td>

<td class='even'>&nbsp;<input type='submit' class='button' name='submit'  id='submit' value=' Submit ' onclick="ccc(this.form,this)" /></form></td></tr>

</table>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center">
<table width='80%' class='grid' cellspacing='1' align='center'><tr><td colspan='10' class='title' align="center">Programs list</td></tr>
<tr valign='middle' align='left'></tr>
  <tr valign='middle' align='left'>
  <td class='odd' width='10%'>ID</td>
  <td class='even' width='20%'>Name</td>
  <td class='odd' width='55%'>Description</td>
  <td class='even' width='10%'>Priority</td>
  <td class='odd' width='10%'>Position</td>
<td class='even' width='15%'>Action</td>  

  </tr>
  {% for at in pj %}
 
  <tr valign='middle' align='left'>
  <td class='odd'>{{at.id}}</td>
   <td class='even'>{{at.name}}</td>
   <td class='odd'>{{at.intro}}</td>
   <td class='even'>{{at.imvalue}}</td>
   <td class='odd'>{{at.position}}</td>
<td class='odd' ><a href="/edit_pj/{{ at.id}}">Edit</a>&nbsp;&nbsp;&nbsp;{% ifequal level 'administrators' %}<a href="/del_pj/{{ at.id}}" onclick="return confirm('Are you sure to delete it?');">Delete</a>{%endifequal%}</td>
  </tr>

  {% endfor %}

      <tr><td  class='even' colspan="10" align="right">
{% if is_paginated %}
                    {% ifequal current_page 1 %}first 
                    {% else %} <a href="/pjlist">first</a>
                    {% endifequal %}
                    {% if has_previous %} <a href="/pjlist/{{ previous_page }}/">prev</a>
                    {% else %} prev
                    {% endif %}
                    {% if has_next %}<a href="/pjlist/{{ next_page }}/">next</a>
                    {% else %}next
                    {% endif %}
                    {% ifequal current_page pages %}last
                    {% else %} <a href="/pjlist/{{ pages }}/">last</a>
                    {% endifequal %}
                    &nbsp;&nbsp;
                    Current：{{ current_page }}/{{ pages }}&nbsp;&nbsp;
                {% endif %}              
               {{ hits }} Records 
</td></tr>
</table>


{% endblock %}